#导包
from re import I
from flask import Flask
from flask.blueprints import Blueprint
#导包跨域
from flask_cors import CORS
from hhh import users
#导入基础模块
from flask import request,jsonify
#导入时间模块
import time

#建立flask实例
app = Flask(__name__)

#利用跨域模块进行封装
CORS(app,cors_allowed_origins='*')
#导入用户模块
from user_view import user
#解决中文乱码
app.config['JSON_AS_ASCII']=False

#注册蓝图
from course_view import course
from xxx import hhh
from goodss import good
from zkaoshi import kaoshi
app.register_blueprint(user)
app.register_blueprint(users)
app.register_blueprint(course)
app.register_blueprint(hhh)
app.register_blueprint(good)
app.register_blueprint(kaoshi)


#视图
@app.route('/',methods=['GET','POST','DELETE','PUT'])
def hello_word():
    data = request.args.get('gid')
    id = request.form.get('id')
    data1 = request.args.get('id')
    print(data1)
    data2 = request.args.get('did')
    print(data2)
    data3 = request.form.get('name')
    print(data3)
    return {'code':200,'msg':'hello world'}


#耗时任务
async def get_data():
    time.sleep(5)

#性能接口
@app.route('/data/')
async def mydata():
    print('开始执行')
    # time.sleep(5)
    await get_data()
    print('结束执行')
    return {'msg':322}

#调用实例对象
if __name__== '__main__':
    app.run(debug=True,host='127.0.0.1',port = 5000)

# 